-
Notifications
You must be signed in to change notification settings - Fork 7.6k
init: fix compilation for broken compilers #93027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Some (broken) compilers fail to handle struct x { union { type_a *a; type_b *b; }; }; correctly. Replace that with an equivalent but simpler union x { type_a *a; type_b *b; }; Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
|
As explained in #93020 this bug can also be reproduced by building pure Zephyr for intel_adsp/cavs25 using the same Cadence toolchain |
This removes the encapsulation, though. With a struct, more members can be added later without breaking an API. |
@lyakh - it looks like the code is being compiled with Maybe the compiler isn't actually broken. Can you try building with the appropriate settings? With Zephyr, you should be able to use |
@henrikbrixandersen correct, and it does look like a compiler bug. And we don't know what exactly it failed to digest - an anonymous union within a structure (which would be a bit strange, because there are probably more examples of that both in Zephyr and SOF, for which that compiler is routinely used), or such a union as a single element of a structure, which might indeed be rather rare, so maybe it's exactly this that tripped the compiler. So, my "hope" is, that if we do need to add more fields in the future, we restore the structure, but then the union won't be the only member there, so maybe that will satisfy the compiler. Or maybe by then we'll update the compiler. |
@cfriedt have just tried that:
and we do have multple locations in SOF with anonymous unions, e.g. https://github.com/thesofproject/sof/blob/97fbd9938f72a5cdabc76fddc626c24c2858e6cd/src/audio/mux/mux.h#L169 and it does get used in those builds - I've checked it by adding a bug there, and (without the added bug) that union builds just fine |
Some (broken) compilers fail to handle
correctly. Replace that with an equivalent but simpler
Sample build failure log: https://sof-ci.01.org/sofpr/PR10113/build13856/build/firmware_community/tgl.log